import React, { useEffect } from 'react';
import { useState } from 'react';
import { useHistory } from "react-router-dom"
import {
    Button,
    Form,
    Input,
    Select,
} from 'antd';
import service from '../../../utils/service';
function AddStudent() {
    const history = useHistory();
    // 事件
    const onFinish = (values: any) => {
        service({
            url: `/studentdata`,
            method: 'post',
            data: {
                ...values
            }
        }).then(res => {
            if (res.status === 200 || res.status === 201) {
                console.log(res, "res")
                history.push("/Main/studentManagement")
            }

        })
    };
    const tocancel=()=>{
        history.push("/Main/studentManagement")
    }
    return (
        <div className='studentManagEditor'>
            <div className='top'>编辑</div>
            <div className='content'>
                <div className='contentinfor'>
                    <Form
                        labelCol={{ span: 4 }}
                        wrapperCol={{ span: 14 }}
                        layout="horizontal"

                        style={{ maxWidth: 600 }}

                        onFinish={onFinish}
                    >
                        <Form.Item
                            label="id"
                            name='id'
                            hidden
                        >
                            <Input />
                        </Form.Item>
                        <Form.Item
                            label="学生姓名"
                            name='name'
                        >
                            <Input />
                        </Form.Item>
                        <Form.Item label="学籍号" name="num">
                            <Input />
                        </Form.Item>
                        <Form.Item label="年级" style={{ marginBottom: 0 }}>
                            <Form.Item name="grand" >
                                <Select

                                    style={{ width: 120 }}

                                    options={[
                                        { value: '全部', label: '全部' },
                                        { value: '一年级', label: '一年级' },
                                        { value: '二年级', label: '二年级' },
                                        { value: '三年级', label: '三年级' },
                                        { value: '四年级', label: '四年级' },
                                        { value: '五年级', label: '五年级' },
                                        { value: '六年级', label: '六年级' },
                                    ]}>
                                </Select>

                            </Form.Item>
                            <Form.Item name="class" label='班级 ' >
                                <Select
                                    style={{ width: 120, marginLeft: 10 }}

                                    options={[
                                        { value: '全部', label: '全部' },
                                        { value: '1班', label: '1班' },
                                        { value: '2班', label: '2班' },
                                        { value: '3班', label: '3班' },
                                        { value: '4班', label: '4班' },
                                        { value: '5班', label: '5班' },
                                        { value: '6班', label: '6班' },
                                    ]}>
                                </Select>
                            </Form.Item>
                        </Form.Item>
                        <Form.Item label="性别" name="sex">
                            <Input />
                        </Form.Item>
                        <Form.Item label="民族" name="nation">
                            <Input />
                        </Form.Item>
                        <Form.Item label="监护人姓名" name="name1">
                            <Input />
                        </Form.Item>
                        <Form.Item label="监护人手机号" name="phone1">
                            <Input />
                        </Form.Item>
                        <Form.Item label="" style={{}}>
                            <Button type="primary" htmlType="submit">提交</Button>
                            <Button style={{ marginLeft: 20 }} onClick={tocancel} >取消</Button>
                        </Form.Item>
                    </Form>
                </div>
            </div>
        </div>
    )
}

export default AddStudent
